<%@ page contentType="text/html; charset=UTF-8" %>
<%@ taglib prefix="s" uri="/struts-tags"%>
<%@ taglib uri="http://displaytag.sf.net/el" prefix="display" %>

<html>

  <head>
    <title><s:text name="invoicesaction.title"/></title>
  </head>

  <body>

    <p class="wwPageTitle">
      <img src="<s:url value='/images/invoice.gif'/>"/>
      <s:text name="invoicesaction.detailsSlash">
        <s:param value="model.hrInvoiceNumber"/>
      </s:text>
    </p>

    <s:actionerror />
    <s:actionmessage/>
    <s:fielderror />

    <table class="wwFilterTable">

      <tr>
        <th colspan="2">
          <s:text name="invoice.purchaserData"/>
        </th>
      </tr>

      <tr>
        <td class="tdLabel">
          <s:label key="invoice.purchaserName"
                   theme="simple"
                   cssClass="label" />:
        </td>
        <td>
          <s:property value="%{purchaserNameHTML}" escape="false"/>
        </td>
      </tr>

      <tr>
        <td class="tdLabel">
          <s:label key="invoice.purchaserAddress"
                   theme="simple"
                   cssClass="label" />:
        </td>
        <td>
          <s:property value="%{purchaserAddressHTML}" escape="false"/>
        </td>        
      </tr>

      <s:label key="invoice.purchaserNip"
               value="%{model.purchaserNip}" />

      <tr>
        <th colspan="2">
          <s:text name="invoice.timeData"/>
        </th>
      </tr>

      <s:text id="documentDate" name="format.date">
        <s:param value="model.documentDate"/>
      </s:text>
      <s:label key="invoice.documentDate"
               value="%{#documentDate}" />

      <s:text id="soldDate" name="format.date">
        <s:param value="model.soldDate"/>
      </s:text>
      <s:label key="invoice.soldDate"
               value="%{#soldDate}" />

      <s:text id="paymentDate" name="format.date">
        <s:param value="model.paymentDate"/>
      </s:text>
      <s:label key="invoice.paymentDate"
               value="%{#paymentDate}" />

      <s:text id="paymentKind" name="%{paymentKind.descriptionKey}"/>
      <s:label key="invoice.paymentKind"
               value="%{#paymentKind}" />

    </table>
    
    <table class="wwFilterTable">
    
      <tr>
        <th rowspan="2"><s:text name="invoicePosition.quantity"/></th>
        <th rowspan="2"><s:text name="invoicePosition.serviceName"/></th>
        <th rowspan="2"><s:text name="invoicePosition.symbol"/></th>
        <th rowspan="2"><s:text name="invoicePosition.measure"/></th>
        <th rowspan="2"><s:text name="invoicePosition.priceNetto"/></th>
        <th rowspan="2" class="colValueNetto"><s:text name="invoicePosition.valueNetto"/></th>
        <th colspan="2"><s:text name="invoicePosition.tax"/></th>
        <th rowspan="2" class="colTotal"><s:text name="invoicePosition.total"/></th>
      </tr>

      <tr>
        <th class="colInterestRate"><s:text name="invoicePosition.interestRate"/></th>
        <th class="colSum"><s:text name="invoicePosition.sum"/></th>
      </tr>
      
      <s:iterator value="model.invoicePositions">
      
      <tr>
        <td class="integer">
          <s:property value="quantity"/>
        </td>
        <td>
          <s:property value="serviceName"/>
        </td>
        <td>
          <s:property value="symbol"/>
        </td>
        <td>
          <s:property value="measure"/>
        </td>
        <td class="money">
          <s:text name="format.money">
            <s:param value="priceNetto"/>
          </s:text>
        </td>
        <td class="money">
          <s:text name="format.money">
            <s:param value="valueNetto"/>
          </s:text>
        </td>
        <td class="integer">
          <s:text name="format.integer">
            <s:param value="interestRate"/>
          </s:text>%
        </td>
        <td class="money">
          <s:text name="format.money">
            <s:param value="sum"/>
          </s:text>
        </td>
        <td class="money">
          <s:text name="format.money">
            <s:param value="total"/>
          </s:text>
        </td>
      </tr>
      
      </s:iterator>
      
      <%-- separator --%>
      <tr>
        <td colspan="9" class="cellUnderlined">&nbsp;</td>
      </tr>
      
      <%-- podsumowanie --%>
      <tr>
        <td colspan="4">&nbsp;</td>
        <td class="money">
          <b><s:text name="invoicePosition.allTogether"/></b>
        </td>
        <td class="money">
          <s:text name="format.money">
            <s:param value="model.calculatedSummaries[1.0].valueNetto"/>
          </s:text>
        </td>
        <td>
          &nbsp;
        </td>
        <td class="money">
          <s:text name="format.money">
            <s:param value="model.calculatedSummaries[1.0].sum"/>
          </s:text>
        </td>
        <td class="money">
          <s:text name="format.money">
            <s:param value="model.calculatedSummaries[1.0].total"/>
          </s:text>
        </td>
      </tr>

      <s:iterator id="key" value="model.calculatedSummariesKeys" status="status">
      <tr>
        <td colspan="4">&nbsp;</td>
        <td class="money">
          <s:if test="#status.first">
            <b><s:text name="invoicePosition.allTogetherFactors"/></b>
          </s:if>
        </td>
        <td class="money">
          <s:text name="format.money">
            <s:param value="model.calculatedSummaries[#key].valueNetto"/>
          </s:text>
        </td>
        <td class="integer">
          <s:text name="format.integer">
            <s:param value="model.calculatedSummaries[#key].interestRate"/>
          </s:text>%
        </td>
        <td class="money">
          <s:text name="format.money">
            <s:param value="model.calculatedSummaries[#key].sum"/>
          </s:text>
        </td>
        <td class="money">
          <s:text name="format.money">
            <s:param value="model.calculatedSummaries[#key].total"/>
          </s:text>
        </td>
      </tr>
      </s:iterator>

    </table>

    <s:form action="invoices/list"
            method="POST"
            cssClass="wwFilterTable">
      <tr>
        <td colspan="9" class="wwFilterTableButtonBar">
          <s:submit key="button.back" cssClass="inputButton" theme="simple" action="invoices/list" />
          
          <s:url id="printLink" namespace="/print" action="invoices/showDr">
            <s:param name="id" value="%{id}" />
          </s:url>
          <s:submit key="button.print"
                    cssClass="inputButton"
			        theme="simple"
			        onclick="printUrlInWindow('%{printLink}', 'actionDetailsPrint'); return false;" />
		</td>
      </tr>

    </s:form>
    
  </body>

</html>
